package juc.test;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

@Slf4j(topic = "c.FutureUse")
public class FutureUse {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<Integer> task = new FutureTask<>(
                () -> {
                    log.debug("running...");
                    Thread.sleep(2000);
                    return 100;
                }
        );
        Thread t = new Thread(task, "t1");
        t.start();

        log.debug("{}", task.get());
    }
}
